#!/usr/bin/python3
# -*- coding:utf-8 -*-
# __author__ == taoyulong2018@gmail.com
# __time__ == 2023/8/1 10:21
# ===========================================
#       题目名称： 81. 搜索旋转排序数组 II
#       题目地址： https://leetcode.cn/problems/search-in-rotated-sorted-array-ii/
#       题目描述： https://note.youdao.com/s/LWYgPSzT
# ===========================================


class Solution:
    def search(self, nums, target):
        """
            没看懂 说是用二分查找法
        """
        left, right = 0, len(nums) - 1
        while right >= left:
            if nums[left] == target:
                return True
            else:
                left += 1
            if nums[right] == target:
                return True
            else:
                right -= 1
        return False

if __name__ == '__main__':
    s = Solution()
    # True
    print("nums = [2,5,6,0,0,1,2], target = 0  =>", s.search(nums=[2, 5, 6, 0, 0, 1, 2], target=0))
    # False
    print("nums = [2,5,6,0,0,1,2], target = 3 =>", s.search(nums=[2, 5, 6, 0, 0, 1, 2], target=3))
